
#include "iostream"
#include "vector"
#include "unordered_map"
#include "unordered_set"
#include "algorithm"
#include "string"
#include "list"
#include "string.h"

class OneLoop{
public:
    std::vector<int> num;
    OneLoop(){
    }
    bool is_huiwen(int i){
        int ws=1;
        int i_bak=i;
        while(i){
            i/=10;
            ws*=10;
        }
        ws/=10;
        i=i_bak;
        while(ws>1){
            int begin=i%10;
            int end=i/ws;
            if(begin!=end){
                return false;
            }
            i%=ws;
            i/=10;
            ws/=100;
        }
        return true;
    }
    void run(int n){
        for(int i= std::max(1000,n);i<10000;i++){
            if(is_huiwen(i)){
                std::cout<<i<<std::endl;
            }
        }
    }
};
class Solution {
public:
    void run() {

        bool first = true;
        int a;
        while (std::cin>>a) {
            OneLoop loop;
            loop.run(a);
        }
    }
};

int main() {
//    bool cur_num= true;
    Solution().run();
    return 0;
}

